﻿@COFE ?= {}
Link = COFE.Link
Entry = COFE.Entry

# MODEL - Represents COFEWS Entry's metadata.
class EntryMeta extends Spine.Model
  # id - EntryId, also used to lookup cached EntryMeta.
  # data - an array contains pairs of key and value.
  @configure 'EntryMeta', 'id', 'data'
  
  # Init
  init : ->    

  # Construct EntryMeta from cache using an id.
  EntryMeta.fromId = (id) ->
    EntryMeta.findByAttribute('id', id) 

  # Construct EntryMeta from from COFEWS EntryMetadata.
  EntryMeta.fromJson = (id, data) ->
    entryMeta = EntryMeta.fromId(id)
    if entryMeta isnt null
      return entryMeta

    entryMeta = EntryMeta.init({
      id : id
      data : data
      })
    entryMeta.save
    return entryMeta    

COFE.EntryMeta = EntryMeta
